package com.rjwh.dingdong.client.mvp.model.impl;

import com.aishua.lib.task.AsResult;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.mvp.BaseModel;
import com.rjwh.dingdong.client.mvp.BasePresenter;
import com.rjwh.dingdong.client.mvp.model.IHomeWorkFansListModel;
import com.rjwh.dingdong.client.network.HttpWebService;
import com.rjwh.dingdong.client.network.HttpWebServiceCallBack;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 王小珂
 * @ClassName HomeWorkFansListModel
 * @Description
 * @date 2017-1-6
 * @history 2017-1-6 author: description:
 */

public class HomeWorkFansListModel extends BaseModel implements IHomeWorkFansListModel, HttpWebServiceCallBack {

    public HomeWorkFansListModel(BasePresenter basePresenter) {
        super(basePresenter);
    }


    /**
     * 我的粉丝|我的关注
     *
     * @param type
     * @param pageindex
     * @param isRefresh
     */
    @Override
    public void doGetHomeWorkFansFollowList(int type, int pageindex, boolean isRefresh) {
        Map<String, String> params = new HashMap<>();
        params.put("type", String.valueOf(type));
        params.put("pageindex", String.valueOf(pageindex));
        HttpWebService.getDataFromServer(NetConstant.GETHOMEWORKFANSFOLLOWLIST, params, isRefresh, this);
    }

    /**
     * 关注/取消关注
     *
     * @param operation
     * @param fansid
     */
    @Override
    public void doHomeWorkFollowOperation(String operation, String fansid) {
        Map<String, String> params = new HashMap<>();
        params.put("operation", operation);
        params.put("fansid", fansid);
        HttpWebService.getDataFromServer(NetConstant.HOMEWORK_FOLLOW, params, true, this);
    }

    @Override
    public void onServerDataAcquired(int businessType, AsResult mAsResult, boolean isRefresh) {
        if (getBasePresenter() != null) {
            getBasePresenter().onServerDataAcquired(businessType, mAsResult, isRefresh);
        }
    }
}
